// pages/tabs/home/index.js
const gotop = require('../../../_pub/com/wx/gotop')
const { $wx, img, $http, target } = getApp()
const site = 'home'
Page({
    data: {
        img,
        nav:[
            { title:'在售房源', icon:'icon/1.png', url:'/pages/tabs/house/index', type:'tab' },
            { title:'预约看房', icon:'icon/2.png', url:'/pages/look_house/index' },
            { title:'帮我找房', icon:'icon/3.png', url:'/pages/find_house/index' },
            { title:'我要推荐', icon:'icon/4.png', url:'/pages/rec/index' }
        ],
        data:[],
        colors: ['rgb(244, 175, 247)', 'rgb(244, 175, 100)']
    },
    /* -------------------------------------------------  */
    async paging(o){ await $http.paging(this, 'room', { query:{ rec_type:'01' }, ...o } ) },
    
    /* -------------------------------------------------  */ 
    async onLoad(){ 
        this.auth();
        await $http.pull(this,'ad', { dataName:'swiperData', param:{ many:1,location:'01', target }, auth:1 })
        $http.pull(this,'ad', { dataName:'newData', param:{ many:0,location:'03',target } })
        $http.pull(this,'ad', { dataName:'videoData', param:{ many:0,location:'04',target } })
        $http.pull(this,'loupan', { dataName:'loupan'})
        this.friend = await $wx.share.friend(this, { param:{ site, target } })
        this.collect = await $wx.share.collect(this, { param:{ site, target  } })
    },
    async auth(){
        this.paging({ refresh:true })
    },
    onPullDownRefresh(){ $wx.refresh(this, 'auth')  },
    onUnload(){ $http.abort(this) },
    async onReachBottom() { await this.paging() },
    onPageScroll(e){ gotop.scroll(this, e) },
    /* -------------------------------------------------  */ 
    onShareAppMessage(e) { return $wx.share.msg(this, { param:{ site, target } }) },
    onShareTimeline(){ return this.friend },
    onAddToFavorites(){ return this.collect },
})